<?
// mcGallery - Marc Cagninacci - marc@phpforums.net - http://www.phpforums.net

include './conf.inc.php';
include './header.php';
include './shadow.php';
include './lang/'.$lang;
?>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" valign="top" width="35%">
<table border="0" cellspacing="1" cellpadding="2" width="100%">
<tr>
<td bgcolor="#OOOOOO" colspan="2"><font face="verdana" size="4" color="white"><? echo $page_title; ?></font>   </td>
   </tr>
   <tr>
<?
$connect= mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);

$query="SELECT idalbum, COUNT(idalbum) FROM mcgallery GROUP BY idalbum";
$result=mysql_query($query);
$nbre_album= mysql_num_rows($result);
if ($nbre_album==1)
{
  $album_unique=mysql_fetch_row($result);
  $album=$album_unique[0];
  echo '<td>&nbsp;</td></tr>';
}
elseif ($nbre_album>1)
{
  ?>

   <td bgcolor="#OOOOOO" colspan="2"><font face="verdana" size="2" color="white"><? echo $l_Albums; ?></font>   </td>
   </tr>
   <?
$query="SELECT idalbum, album, COUNT(id) FROM mcgallery GROUP BY idalbum";
$result=mysql_query($query);
 while($row=mysql_fetch_row($result))
 {
    echo '<tr><td bgcolor="#CCCCCC"><font size="1">';
    if ($row[0]==$album)  { echo '<b>'; }
    echo '<a href="index.php?album='.$row[0].'" class="lien1">'.stripslashes($row[1]).'</a>';
    if ($row[0]==$album)  { echo '</b>'; }
    echo '</font></td>';
    echo '<td bgcolor="#CCCCCC"><font face=" verdana" color="black" size="1">'.$row[2].' '.$l_photos.'</font></td></tr>';
 }
    echo '<td bgcolor="black" align="right" colspan="2"><font face="verdana" size="1"><a href="http://www.phpforums.net/index.php?dir=dld" class="lien2" target="_blank">powered by <b>mcGallery</b></a></font></td></tr>';
}
?>
<tr>
<td>
<?
if ($album=='')
{
  echo '<font face="verdana" size="4" color="black">mcGallery</font><br>';
  echo '<font face="verdana" size="2" color="black">'.$l_Select.'</font>';
}
else
{
$query="SELECT id, album FROM mcgallery WHERE idalbum='$album'";
$result=mysql_query($query);
$nbre=mysql_num_rows($result);
$row2=mysql_fetch_array($result);
echo '<table border="0" cellspacing="0" cellpadding="5"><tr>';
echo '<td align="center" bgcolor="black" colspan="2">';
echo '<font face="verdana" size="2" color="white">'.stripslashes($row2['album']).'</font></td>';
echo '<td bgcolor="black" align="right">';

if ($start=='') { $start=0; }
$query="SELECT file, title FROM mcgallery WHERE idalbum=$album ORDER BY file LIMIT $start, 9";
$result=mysql_query($query);
echo '<font face="verdana" size="1" color="white">('.$nbre.' '.$l_photos.')</font></td><tr>';
  $j=0;
  $k=0;
  while ($row2=mysql_fetch_array($result))
  {
  $len= strlen($album);
  $image= substr($row2['file'], ($len + 1));
  echo '<td bgcolor="white" align="center">'.shadow($album, $image, $start);
  echo '<font face="verdana" color="black" size="1">';
   if ($row2['title']!='')  { echo stripslashes($row2['title']); }
   else  { echo '&nbsp;'; }
  echo '</font></td>';
  $j++;
   if ($j%3==0)
   {
   echo '</tr><tr>';
   $k++;
   }
  }
       if ($j%3==2) { echo '<td bgcolor="white">&nbsp;</td></tr><tr>'; }
       if ($j%3==1) { echo '<td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td></tr><tr>'; }
 $k++;
       if ($k==1)
       {
       echo '<td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td></tr>';
       echo '<tr><td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td></tr><tr>';
       }
       if ($k==2)
       {
       echo '<td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td><td bgcolor="white">&nbsp;</td></tr><tr>';
       }
echo '<td bgcolor="black" colspan="3" align="right">';
echo '<font face="verdana" color="white" size="1">'.$l_page.':&nbsp;&nbsp;</font>';
// navigation
$i=1;
while ($i<(($start + 9)/9))
 {
   echo '<font face="verdana" size="1"><a href="index.php?start='.(9*($i-1)).'&album='.$album.'" class="lien2">'.$i.'</a></font>&nbsp;';
   $i++;
 }
 echo '<font face="verdana" color="white" size="1"><b> '.$i.' </b></font>&nbsp;';
 $i++;
while ($i<=ceil($nbre/ 9))
 {
   echo '<font face="verdana" size="1"><a href="index.php?start='.(9*($i-1)).'&album='.$album.'" class="lien2">'.$i.'</a></font>&nbsp;';
   $i++;
 }
//  fin navigation
$query= "SELECT descr FROM mcgallery_album WHERE idalbum=$album";
$res= mysql_query($query);
$alb_descr= mysql_fetch_row($res);
  if ($alb_descr[0]!='')
  {
  echo '</td></tr>';
  echo '<tr><td bgcolor="#CCCCCC" colspan="3" width="'.(($thumb_width * 3) + 30).'"><font face=" verdana" color="black" size="1">';
  echo nl2br(stripslashes($alb_descr[0])).$width;
  echo '</font></td></tr>';
  echo '<tr><td bgcolor="#000000" colspan="3" height="4">';
  }
 echo '</td></tr></table>';
}
?>
</td>
</tr>
  </table></td>
</tr>
</table>
<?
include './footer.php';
?>